/******************************************************************************
 * Copyright 2018 The Apollo Authors. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *****************************************************************************/

/**
* @file
**/

#ifndef MODULES_COMMON_UTIL_THREAD_POOL_H_
#define MODULES_COMMON_UTIL_THREAD_POOL_H_

#include <memory>

#include "ctpl/ctpl_stl.h"
#include "modules/common/macro.h"

namespace apollo {
namespace common {
namespace util {

/**
* @class ThreadPool
*
* @brief A wrapper around ctpl thread pool.
* TODO(authors): Eventually migrate other threadpool usages to this.
*/

class ThreadPool {
 public:
  static void Init(int pool_size);

  static ctpl::thread_pool* pool();

  static void Stop();

 private:
  std::unique_ptr<ctpl::thread_pool> pool_;

  DECLARE_SINGLETON(ThreadPool);
};

}  // namespace util
}  // namespace common
}  // namespace apollo

#endif  // MODULES_COMMON_UTIL_THREAD_POOL_H_
